﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using SharpBolt.Basics;
using SharpBolt;
using InductBase;
using SharpBolt.Graphics;
using SharpBolt.Graphics.Structs;
using SharpBolt.Graphics.GraphicSources;
using SharpBolt.Graphics.GraphicInstances;

using SharpBolt.Sound;
using SharpBolt.Input;

using InductBase.Extensions;

using PowerOne;
using PowerOne.GraphicUtilites;
using PowerOne.SoundUtilites;
using PowerOne.InputUtilites;

using TestGame.Logic;

namespace TestGame
{
    class Game : PowerWindow
    {

        bBitmap bmp;
        SpriteSource spriteSrc;
        SpriteInstance sprite;
        RasterFontSourse fontSrc;
        
        Vec2 test;

        PlayRoom playRoom;

            [STAThread]
            static void Main() {
                using (var Game = new Game()) {
                    Game.Run(60);
                }
            }

            SoundPlayer sound;            

            public Game() {
                playRoom = new PlayRoom();
            }            

            protected override void OnLoad(EventArgs E) {
                base.OnLoad(E);
                //OpenGLRender.SetFiltering(OpenTK.Graphics.OpenGL.TextureMinFilter.Nearest);
                fontSrc = RasterFontSourse.LoadIndieFont(@"fonts\font_big");
                fontSrc.CharsInterval = -10;
                playRoom.Init();
                Global.GraphicRender.View = new Rec(0, 0, 640, 480);
               

            }
        
            protected override void OnResize(EventArgs E) {
                base.OnResize(E);              
            }
                

            protected override void OnUpdateFrame(FrameEventArgs E) {
                base.OnUpdateFrame(E);              
                playRoom.Update();
            }

            protected override void OnRenderFrame(FrameEventArgs E) {
                base.OnRenderFrame(E);

                Global.GraphicRender.BeginDraw();             
                playRoom.Draw(Global.Painter);
                fontSrc.Draw(Global.Painter, Transformation.Default.Move(new Vec2(100,100)).Rotate(0),"Hello world!", Colors.Red);
                Global.GraphicRender.EndDraw(); 
               
                SwapBuffers();
            }

        }
    
}
